package com.example.health_hjk;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;
import androidx.core.view.GravityCompat;
import androidx.drawerlayout.widget.DrawerLayout;

import com.example.health_hjk.food_grid.FoodGridActivity;
import com.example.health_hjk.food_list.InfoListActivity;

public class HomeMenuActivity extends AppCompatActivity {

    private DrawerLayout mDrawerLayout;//滑动菜单
    private TextView mTvcehua,mTvhome_btn1,mTvhome_btn2,mTvhome_btn3,mTvhome_btn4,mTvhome_btn5;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_home_menu);

        mDrawerLayout = findViewById(R.id.drawer_layout);
        mTvcehua = findViewById(R.id.tv_cehua);
        mTvhome_btn1 = findViewById(R.id.home_btn1);
        mTvhome_btn2 = findViewById(R.id.home_btn2);
        mTvhome_btn3= findViewById(R.id.home_btn3);
        mTvhome_btn4= findViewById(R.id.home_btn4);
        mTvhome_btn5= findViewById(R.id.home_btn5);

        OnClick onClick = new OnClick();
        mTvcehua.setOnClickListener(onClick);
        mTvhome_btn1.setOnClickListener(onClick);
        mTvhome_btn2.setOnClickListener(onClick);
        mTvhome_btn3.setOnClickListener(onClick);
        mTvhome_btn4.setOnClickListener(onClick);
        mTvhome_btn5.setOnClickListener(onClick);
    }

    class OnClick implements View.OnClickListener {
        Intent intent = new Intent();

        @Override
        public void onClick(View v) {
            switch (v.getId()) {
                case R.id.home_btn1:
                    intent.setClass(HomeMenuActivity.this, InfoListActivity.class);
                    startActivity(intent);
                    //System.out.println("点击了btn1");
                    break;
                case R.id.home_btn2:
                    intent.setClass(HomeMenuActivity.this, FoodGridActivity.class);
                    startActivity(intent);
                    //System.out.println("点击了btn1");
                    break;
                case R.id.home_btn3:
                    intent.setClass(HomeMenuActivity.this, AboutActivity.class);
                    startActivity(intent);
                    break;
                case R.id.home_btn4:
                    intent.setClass(HomeMenuActivity.this, VideoPlayerActivity.class);
                    startActivity(intent);
                    break;
                case R.id.home_btn5:
                    intent.setClass(HomeMenuActivity.this, exercise_food.class);
                    startActivity(intent);
                    break;
                case R.id.tv_cehua:
                    //打开滑动菜单  左侧出现
                    mDrawerLayout.openDrawer(GravityCompat.START);
                    break;
            }

        }
    }
}